from django.db import models


# Create your models here.
class Category(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100)
    type = models.IntegerField() #0:导航，1、文章列表，2、内容类型，3、图片，4、超链接
    is_nav = models.BooleanField(default=False)
    is_index = models.BooleanField(default=False)
    href = models.CharField(max_length=100, null=True, blank=True)
    create_date = models.DateTimeField(auto_now_add=True)
    parent = models.ForeignKey(to="self", on_delete=models.SET_NULL, null=True, blank=True)
    orders = models.IntegerField() #排序号

    class Meta:
        db_table = 't_category'


class Topic(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=255)
    content = models.TextField(null=True, blank=True)
    create_date = models.DateTimeField(auto_now=True)
    release_date = models.DateTimeField()
    author = models.CharField(max_length=100)
    category = models.ForeignKey("Category", on_delete=models.SET_NULL, null=True, blank=True)

    class Meta:
        db_table = 't_topic'
